package MineGod;

import org.lwjgl.opengl.GL11;

/*
 * Get smaller
 * go from red to yellow
 * speed up
 */
public class FireParticle extends Particle {

	public double maxSize;
	public double size;
	public double initialLife;
	
	public double iR = 1.0; //initial red value
	public double iG = 0.0;
	public double iB = 0.0;
	public double fR = 1.0; //final red value;
	public double fG = 1.0;
	public double fB = 0.0;
	
	public double red = iR;
	public double green = iG;
	public double blue = iB;
	
	public FireParticle(double life, double xPos, double yPos, double xSpeed, double ySpeed){
		super(life, xPos, yPos, xSpeed, ySpeed);
		initialLife = life;
		maxSize = 5;
		
	}
	
	public void update(int delta){
		super.update(delta);
		size = (life / initialLife) * maxSize;
		red = iR + (life / initialLife) * (fR-iR);
		green = iG + (life / initialLife) * (fG-iG);
		blue = iB + (life / initialLife) * (fB-iB);
	}
	
	public void render(){
		double renderX;
		if (MineGod.player.xPos<Chunk.CHUNK_PIXEL_WIDTH/2){
			renderX = 0;
			initialX = MineGod.player.xPos;
		}else{
			renderX = initialX-MineGod.player.xPos;
		}
		GL11.glDisable(GL11.GL_TEXTURE_2D);
		GL11.glBegin(GL11.GL_QUADS);
			GL11.glNormal3d(0, 0, 1);
			GL11.glColor3d(red, green, blue);
			GL11.glVertex3d(renderX+xPos, yPos, -.99);
			GL11.glColor3d(red, green, blue);
			GL11.glVertex3d((renderX+xPos + size), yPos, -.99);
			GL11.glColor3d(red, green, blue);
			GL11.glVertex3d((renderX+xPos + size), (yPos+size), -.99);
			GL11.glColor3d(red, green, blue);
			GL11.glVertex3d(renderX + xPos, (yPos+size), -.99);
		GL11.glEnd();
	}
}
